﻿using System.Reflection;
using System.Resources;
using Nexxo.Channel.DMS.Web.DMSServices;
using System.ServiceModel;
using System;

namespace Nexxo.Channel.DMS.Web.Common
{
    public static class ExceptionHandler
    {
        private enum CustomerException
        {

            
        }
        public static string GetSOAPExceptionMessage(FaultException<NexxoSOAPFault> nexxoFault)
        {
            string majorcode = nexxoFault.Detail.MajorCode;
            string minorcode = nexxoFault.Detail.MinorCode;
            string errorcode = string.Join(".", new object[] { majorcode, minorcode });

            string errmsg = System.Configuration.ConfigurationManager.AppSettings.Get(errorcode);

            //string basepath = System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\Properties\\";
            //ResourceManager resourcemanager = ResourceManager.CreateFileBasedResourceManager("ExceptionCodes", basepath, null);
            //string errmsg = resourcemanager.GetString(errorcode);
            
            errmsg = (errmsg != null && errmsg != string.Empty) ? errmsg : "UNKNOWN ERROR CODE : Error processing your request, please try again";
            return errmsg;
        }

        public static string GetExceptionMessage(Exception e)
        { 
            return "UNKNOWN ERROR CODE : Error processing your request, please try again"; 
        }

    }
}